ceramicafandomcom-20200216-history
Plantilla:LayoutTemplateArgs/doc
|1def= |1stat=required |2=template |2d= |2def= |2stat=required |name=LayoutTemplateArgs |desc= |namespace=10 |usergroup=all |placement= |usage-notes= Example: } }} } }} } }} } }} }} |type= |example= |i18n-method=- |i18n-desc= |seealso= * MediaWiki talk:AjaxTranslation.js * Template:Autotranslate |setscats= |lines= |shorthand= |relieson= * MediaWiki:AjaxTranslation.js }} Using this template These instructions assume that you're starting with a standard -style template (whether it actually uses or not) with the usual "/layout", "/lang" subpages and one or more "/''xx''" ISO 639 language code subpages. Step 0: First, to enable the in-line translation feature for the template, the outermost containing element for each translated version must be given the "layouttemplate" class if it doesn't already have it. What this means in practice is that you should edit the "/layout" subpage of the template and add class="layouttemplate" to the first tag or table there. (If it already has a class attribute, append "layouttemplate" to the value; e.g. replace class="someclass otherclass" with class="someclass otherclass layouttemplate". If the classes are specified via yet another template, edit that template instead.) If there is no single or table that would enclose the entire content, you can add one: just wrap the whole thing in ... . Finally, make sure there are no other elements with the "layouttemplate" class. If the in-line translation feature already works for your template, you can skip the previous paragraph and start here. Also, if the template takes no parameters, you don't need to do anything more. If it does, do the following: Step 1: Make sure all the parameters given to the template are passed to the "/layout" subpage. If not, you first need to edit all the translated versions of the template so that this is the case. For example, if your template takes three numbered parameters and the named parameter "foo", insert the following lines into each of the translated subpages: |1= } |2= } |3= } |foo= } Step 2: Edit the "/layout" subpage and insert inside the element with the "layouttemplate" class, as early as possible. If the element is a div, you can just put it immediately after the tag; if it's a table, put it at the beginning of the the first table cell. The value of the "args" parameter should contain all the parameters you want to have passed to the translated versions during in-line replacement, individually URL-encoded and separated by whitespace (i.e. spaces or linebreaks; not pipes as in normal template calls). For example, if your template takes the same parameters as above, and is named Template:FooBar, the code you should add to Template:FooBar/layout would be: } }} } }} } }} } }} }} Now test your template to see that it works as expected. If not, fix it or ask for help. Known issues There are a couple of known bugs in this template and in the associated Ajax translation script, including: Parameters containing , , , , , etc. tags turn into gibberish cause the in-line replacement not to work. :This is a known bug in the MediaWiki parser function: when given input containing "parser extension tags", those tags and their content get replaced by internal "strip markers" which look something like "UNIQ77ef13a860481bc0-nowiki-00000010-QINU". Unfortunately, there's no way for the Ajax translation script to work out what the content replaced by such strip markers might've originally been. The current implementation reverts to opening the translated template on a new page if it detects any strip markers in the parameters. Very long parameter values cause the in-line replacement not to work. :The in-line replacement code uses a MediaWiki API query to load the translated version of the template. For simplicity and efficiency, the current implementation uses HTTP GET requests to access the API, which means that the name of the template and all the parameters are included in the query URL. If this URL gets longer than about 4 kilobytes, the servers will reject it as excessively long. The current code simply refuses to generate such long URLs, and reverts to opening the translated template on a new page instead. Autotranslated templates included in parameters will be shown in the user's default language even after in-line replacement. :This happens simply because those templates get parsed and expanded before the Ajax translation code ever sees them. Note that passing complex templates in parameters is also likely to trigger the previous bug as well.